#ifndef SIGNALFLOWCONTROLBOXES_H_JM_20121003
#define SIGNALFLOWCONTROLBOXES_H_JM_20121003

#include "../RootBox.h"

namespace jm4bbx {

	//template<class Descriptor>
	class  SignalCrossBoxTemplate : public Box/*<Descriptor>*/ {
	public:
		SignalCrossBoxTemplate(bobox::box_id_type id, bobox::box_tid_type tid, 
			bobox::request *req, const bobox::parameters &params) 
			: Box(id, tid, req, params) { }

		virtual void initImpl() override {
			wait4SignalsIn();
		}

		virtual void sync_mach_etwas() override {
			sendSignalsOut();
			wait4SignalsIn();
		}
	};


	// cross 

	//struct SignalCrossBoxDescriptor {
	//	//static const char* BOX_ID;
	//};

	class SignalCrossBox : 
		public SignalCrossBoxTemplate/*<SignalCrossBoxDescriptor>*/ {
	public:
		SignalCrossBox(bobox::box_id_type id, bobox::box_tid_type tid, 
			bobox::request *req, const bobox::parameters &params) 
			: SignalCrossBoxTemplate(id, tid, req, params) { }

	};

	// merge

	//struct SignalMergeBoxDescriptor {
	//	//static const char* BOX_ID;
	//};

	class SignalMergeBox : 
		public SignalCrossBoxTemplate/*<SignalMergeBoxDescriptor>*/ {
	public:
		SignalMergeBox(bobox::box_id_type id, bobox::box_tid_type tid, 
			bobox::request *req, const bobox::parameters &params) 
			: SignalCrossBoxTemplate(id, tid, req, params) {

				// Natvrdo len jeden vystrupny signal je to merge
				// inak je mozne pouzit SignalCrossBox.
				setSignalsOut(1);
		}
	};

	// fork

	//struct SignalForkBoxDescriptor {
	//	//static const char* BOX_ID;
	//};

	class SignalForkBox : 
		public SignalCrossBoxTemplate/*<SignalForkBoxDescriptor>*/ {
	public:
		SignalForkBox(bobox::box_id_type id, bobox::box_tid_type tid, 
			bobox::request *req, const bobox::parameters &params) 
			: SignalCrossBoxTemplate(id, tid, req, params) {

				// Natvrdo len jeden vstupny signal je to fork 
				// inak je mozne pouzit SignalCrossBox.
				setSignalsIn(1);
		}
	};

} // namespace jm4bbx


#endif
